package com.pig4cloud.pig.homecenter.util;

import java.sql.Timestamp;
import java.time.Instant;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;

public class DateTimeUtils {

	public static Timestamp hassTimeToTimestamp(String dateTimeStr) {
		DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE_TIME;
		// 解析字符串为ZonedDateTime
		ZonedDateTime zonedDateTime = ZonedDateTime.parse(dateTimeStr, formatter);
		// 将ZonedDateTime转换为Instant
		Instant instant = zonedDateTime.toInstant();
		long millisTimestamp = instant.toEpochMilli();
		Timestamp timestamp = new Timestamp(millisTimestamp);
		return timestamp;
	}

	public static Timestamp now(){
		Timestamp timestamp = new Timestamp(System.currentTimeMillis());
		return timestamp;
	}
}
